Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

feat(uiSelectSingleDirective): add an option to avoid backspace model reset #1736

Merged
merged 8 commits into from
Nov 2, 2016

Conversation

pierregaste
Copy link
Contributor

@pierregaste pierregaste commented Jul 25, 2016

Add a new option that prevent the backspace key reset the model (set to undefined).
Th option could be added to the directive ui-select:

<ui-select disable-backspace-reset="true"></ui-select>

I hope I correctly commit and implement this feature! 😃


feat(uiSelectSingleDirective): add an option to avoid backspace model reset

Currently, when you select an option and you press the backspace key, it will reset the model.
With this option, we could disable this behavior to avoid the model resetting.

Closes #926 #525


This line could be added to the wiki page (uiSelect):

| `backspace-reset` | Set to false to avoid resetting the model when the backspace is pressed  | boolean | true |

… reset

Currently, when you select an option and you press the backspace key, it will reset the model.
With this option, we could disable this behavior to avoid the model resetting.

Closes angular-ui#926 angular-ui#525
@pierregaste
Copy link
Contributor Author

I removed my previous fork by mistake.
d94f076

@@ -83,6 +83,11 @@ uis.directive('uiSelect',
$select.sortable = sortable !== undefined ? sortable : uiSelectConfig.sortable;
});

scope.$watch('disableBackspaceReset', function() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't you be watching the attribute?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, sorry. I fixed it.

@LeleDev
Copy link

LeleDev commented Aug 12, 2016

eagerly waiting for this to be merged

@chardea7
Copy link

we need this compononen.. please merge it ASAP thanks

# Conflicts:
#	src/common.js
#	test/select.spec.js
@pierregaste
Copy link
Contributor Author

Any news about my PR? I just sync the fork.

Thanks for your answer! 😃

@user378230
Copy link
Contributor

user378230 commented Oct 28, 2016

@pierregaste Instead of calling it disableBackspaceReset can we call it backspaceReset set default to true, then user can specify attribute backspace-reset="false" to stop?

If you do this and update tests etc. I promise we will merge!

You appear to have unrelated changes in your commits can you resolve this. Also would help if you squash to single commit for us.

Thanks for your patience!

@user378230
Copy link
Contributor

@pierregaste I just added one more comment too, thanks!

@@ -83,6 +83,10 @@ uis.directive('uiSelect',
$select.sortable = sortable !== undefined ? sortable : uiSelectConfig.sortable;
});

scope.$watch(function () { return scope.$eval(attrs.backspaceReset); }, function(newVal) {
Copy link
Contributor

@user378230 user378230 Oct 28, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use attrs.$observe(...) here instead? Only $eval when value is different. (See resetSearchInput a few lines down)

@pierregaste
Copy link
Contributor Author

pierregaste commented Oct 28, 2016

@user378230 I replace the $watch method by the $observe method. But I don't know how to squash and rebase. Could you help me to do this?

@user378230 user378230 merged commit 7413321 into angular-ui:master Nov 2, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants